﻿using MahApps.Metro.Controls;
using MyWPF.StaticData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace MyWPF.Views.Others
{
    /// <summary>
    /// News.xaml 的交互逻辑
    /// </summary>
    public partial class News : UserControl
    {
        public News(string newsText)
        {
            InitializeComponent();
            NewsText.Text = newsText;
        }

        private void RemoveThis(object sender, RoutedEventArgs e)
        {
            var storyboard = (Storyboard)this.FindResource("RemoveThis");
            //启动
            storyboard.Begin(this);
            Task.Factory.StartNew(() => {
                Thread.Sleep(400);
                Dispatcher.Invoke(new Action(() =>
                {
                    ((StackPanel)this.Parent).Children.Remove(this);
                    StaticModels.vM_MainWindow.NewsNum = StaticModels.mainWindow.NewsRoom.Children.Count;
                }));
            }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);

            
        }


        
    }
}
